package me.sdevil507.biz.fruit.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.sdevil507.supports.jpa.BaseJpaSnowflakeIdEntity;
import me.sdevil507.supports.upload.po.AttachFile;
import org.hibernate.annotations.Formula;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: tips_back_end
 * @description: 报送信息
 * @author: kzl
 * @create: 2020-07-22 19:14
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "biz_fruit_sub")
public class FruitSubPO  extends BaseJpaSnowflakeIdEntity {

    /**
     * 成果id
     */
    @Column
    private Long  fruitId;


    /**
     * 1.报 2.送 3.发
     */
    @Column
    private String  type;


    /**
     * 级别
     */
    @Column
    private String  level;

    @Formula("(select t.d_name from biz_sysdict as t  where t.d_value=level and t.type_key='InclinationsLevel')")
    private String levelName;

    /**
     * 报送部门
     */
    @Column
    private String subDeparment;
    /**
     * 途径部门
     */
    @Column
    private String wayDeparment;

    /**
     * 报送对象
     */
    @Column
    private String subObject;

    /**
     * 是否采用
     */
    @Column
    private Boolean isAdopt;

    /**
     * 采用部门
     */
    @Column
    private String  adoptDeparment;


    /**
     * 采用时间
     */
    @Column
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date  adoptTime;

    /**
     * 采用刊物
     */
    @Column
    private String  adoptJournal;

    /**
     * 备注
     */
    @Column
    private String  remark;

    /**
     * 报送部门类型  1： 江苏省委宣传部(仅在报送智库专报情况下)
     */
    @Column
    private Integer subDeptType;

    /**
     * 报送部门是否处理  0：待处理  1：已采纳  2：未采纳
     * */
    @Column
    private Integer subDeptDealStatus;

    /**
     * 报送时间
     */
    @Column
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date subTime;

    /**
     * 创建时间
     */
    @Column
    private Date createTime = new Date();

    /**
     * 更新时间
     */
    @Column
    private Date updateTime = new Date();

    /**
     * 智库id
     */
    @Column
    private Long orgId;

    /**
     * 平台操作用户id
     */
    @Column
    private Long userId;

    /**
     * 平台操作用户姓名
     */
    @Column
    private String userName;

    /**相关批示附件**/
    @OneToMany(targetEntity = AttachFile.class, cascade= CascadeType.MERGE, orphanRemoval = true)
    @JoinColumn(name="relationId")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<AttachFile> attFiles =new ArrayList<>();

}
